package vues;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import modeles.Contact;
import action.ActionSaveContact;

/**
 * 
 * Class vue Profil de contact
 * profil		Objet Contact
 * homeView		Objet HomeWindow
 * 
 * @author Paul BEZARD-FALGAS
 *
 */
public class ProfilContact extends JFrame{
	private Contact profil;
	private HomeWindow homeView;
	
	public ProfilContact(HomeWindow home, Contact contact){
		super();
		this.homeView = home;
		this.profil = contact;
		build();//On initialise notre fenetre
	}
	
	private void build(){
		this.setTitle("New Contact"); //On donne un titre à l'application
		this.setSize(450,480); //On donne une taille à notre fenêtre
		this.setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
		//setResizable(false); //On interdit la redimensionnement de la fenêtre
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //On dit à la fenetre de se fermer lors du clic sur la croix
		this.setContentPane(buildContentPanel());
	}
	private JPanel buildContentPanel(){
		JPanel panel = new JPanel();
		panel.setLayout(new GridBagLayout());
		panel.setBackground(Color.black);
		//Ajout du titre
		panel.setBorder(BorderFactory.createTitledBorder("PROFIL CONTACT : "));
      
	    //On pr�vient notre JFrame que notre JPanel sera son content pane
	    this.setContentPane(panel);               
	    this.setVisible(true);
	    
		/* 3- Ajout de ce composant au container en sp�cifiant une contrainte de type GridBagConstraints. */
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.insets = new Insets(20, 20, 0, 20);
		gbc.fill = GridBagConstraints.HORIZONTAL;

		//NAME
		gbc.gridx  = 1;
		gbc.gridy  = 1;
		
		JLabel labelName = new JLabel("Name : ");
		panel.add(labelName, gbc);

		gbc.gridx  = 2;
		gbc.gridy  = 1;
		gbc.weightx = 1;
		
		JLabel name = new JLabel(profil.getName());
		panel.add(name, gbc);

		//FIRSTNAME
		gbc.gridx  = 1;
		gbc.gridy  = 2;
		JLabel labelFirstName = new JLabel("FirstName : ");
		panel.add(labelFirstName, gbc);

		gbc.gridx  = 2;
		gbc.gridy  = 2;
		
		JLabel firstName = new JLabel(profil.getFirstName());
		panel.add(firstName, gbc);
		
		//COMPANY ADDRESS
		gbc.gridx  = 1;
		gbc.gridy  = 3;
		
		JLabel labelCmpAddress = new JLabel("Company Address : ");
		panel.add(labelCmpAddress, gbc);
				
		gbc.gridx = 2;
		gbc.gridy = 3;
		
		JLabel cmpAddress = new JLabel(profil.getCompanyAddress());
		panel.add(cmpAddress, gbc);
		
		//PERSONAL PHONE
		gbc.gridx  = 1;
		gbc.gridy  = 4;
		
		JLabel labelPersonalPhone = new JLabel("Personal Phone : ");
		panel.add(labelPersonalPhone, gbc);
		
		gbc.gridx  = 2;
		gbc.gridy  = 4;
		
		JLabel personalPhone = new JLabel(profil.getPersonalPhone());
		panel.add(personalPhone, gbc);
		
		//Bouton validation nouveau contact
		gbc.gridx  = 2;
		gbc.gridy  = 10;
		gbc.weighty = 1.0;
		JButton btnAdd = new JButton("Save");
		//btnAdd.addActionListener();
		panel.add(btnAdd, gbc);
		
		return panel;
	}
}
